package day12;

/*
 * Author: JacksonCoder
 * FileName: AtomicDemo
 * Version: 1.0.0
 * Date: 2025/4/22
 */

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicDemo {

    public static void main(String[] args) {
        AtomicInteger count = new AtomicInteger();

        for(int i = 0; i < 5; i++){
            new Thread(()->{
                for(int j = 0; j < 10000; j++){
                    count.incrementAndGet();
                }
            }).start();
        }

        // 线程等待执行完成
        try{
            Thread.sleep(1000);
        }catch(InterruptedException e){
            e.printStackTrace();
        }

        System.out.println("最终结果：" + count.get());

    }


}
